package com.ncmmall.application.business.subject;

import com.ncmmall.domain.business.subject.SubjectActivityType;
import com.ncmmall.domain.business.subject.SubjectActivityTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;

/**
 * 专题类型管理
 *
 * @author likaikai
 * @date 2020-09-01 10:47:57
 */
@Service
@Transactional
public class SubjectActivityTypeApplication {

    @Autowired
    private SubjectActivityTypeRepository subjectActivityTypeRepository;

    public void create(SubjectActivityType type) {
        type.setStatus(1);
        type.setCreateTime(new Timestamp(System.currentTimeMillis()));
        subjectActivityTypeRepository.save(type);
    }

    public void enable(SubjectActivityType type) {
        type.setStatus(2);
        subjectActivityTypeRepository.save(type);
    }

    public void disable(SubjectActivityType type) {
        type.setStatus(1);
        subjectActivityTypeRepository.save(type);
    }

    public void remove(SubjectActivityType type) {
        subjectActivityTypeRepository.delete(type);
    }
}
